package com.project.service.impl;

import com.project.bean.UserBean;
import com.project.mapper.IUserMapper;
import com.project.service.IUserService;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements IUserService {
    @Autowired
    private IUserMapper mapper;
    @Override
    public UserBean login(String userName, String userPwd) {
        UserBean user = mapper.login(userName,userPwd);
        if (userName==null||userPwd.equals("")){
            return null;
        }
        return user;
    }

    @Override
    public UserBean findByItem(String name, Integer userId) {
        return mapper.findByItem(name,userId);
    }

    @Override
    public void add(UserBean user, Integer[] idArray) {
        mapper.add(user);
        mapper.adds(user.getUserId(),idArray);
    }

    @Override
    public UserBean findById(Integer userId) {
        return mapper.findById(userId);
    }

    @Override
    public void update(Integer id, Integer[] idArray) {
        mapper.update(id,idArray);
    }
}
